import { SearchBar } from 'antd-mobile';
import React from 'react'
import { withRouter } from "react-router-dom";
class SearchBarExample extends React.Component {
    state = {
        value: '',
    };
    onChange = (value) => {
        this.setState({ value });
    };
    clear = () => {
        this.setState({ value: '' });
    };
    onSubmit = () => {
        console.log(this.state.value, 'onSubmit')
        console.log("aaa")
        if (this.state.value === '') { }
        else { this.props.history.push(`/searchdata/${this.state.value}`) }
    };
    render() {
        return (<div className='Search'>
            <SearchBar
                value={this.state.value}
                placeholder="请输入商品名称"
                onSubmit={this.onSubmit}
                onClear={value => console.log(value, 'onClear')}
                onChange={this.onChange}
            />
        </div>);
    }
}

export default withRouter(SearchBarExample)